package de.baumann.browser.present.gg

import de.baumann.browser.api.OdinObserver
import de.baumann.browser.api.net.vo.gg.XXYY
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.gg.IMySmelterView
import de.baumann.browser.model.getPledgeNumAndEarnings

class MySmelterPresenter : BasePresenter<IMySmelterView>() {

    fun a03(id: String, address: String) {
        var a = address
        if (address.startsWith("odx")) {
            a = "0${address.substring(2)}"
        }
        getPledgeNumAndEarnings(a, id)
                .subscribe(object : OdinObserver<XXYY>() {
                    override fun onSuccess(data: XXYY?) {
                        if (data != null) {
                            view?.x(data.EarningsNum)
                            view?.y(data.PledgeNum)
                        }
                    }
                })
    }
}